package com.cskaoyan.controller.wx_xd;

import com.cskaoyan.bean.MarketAddress;
import com.cskaoyan.bean.collect.CollectListVo;
import com.cskaoyan.bean.common.BasePageInfo;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.common.CommonData;
import com.cskaoyan.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author Austin Hsu
 * @Date 2022/9/12 15:25
 */
@RestController
@RequestMapping("wx/address")
public class AddressController {
    @Autowired
    AddressService addressService;

    @RequestMapping("list")
    public BaseRespVo list() {
        CommonData<MarketAddress> data = addressService.query();
        return BaseRespVo.ok2(data);
    }

    @GetMapping("detail")
    public BaseRespVo getDetail(Integer id) {
        MarketAddress data = addressService.getDetail(id);
        return BaseRespVo.ok2(data);
    }

    @PostMapping("save")       //如果是新增 id=0    如果是修改 id=那个被修改的id
    public BaseRespVo postDetail(@RequestBody MarketAddress marketAddress) {
        int i=addressService.postDetail(marketAddress);
        return BaseRespVo.ok2(i);
    }

    @RequestMapping("delete")
    public BaseRespVo deleteDetail(@RequestBody Map<String,Integer> map) {
        addressService.deleteDetail(map);
        return BaseRespVo.ok3();
    }

}
